//
//  UIView+JH_GetCurrentResponseKit.m
//  JiHe
//
//  Created by Mr.Zhang on 16/8/8.
//  Copyright © 2016年 张浩. All rights reserved.
//

#import "UIView+FP_GetCurrentResponseKit.h"

@implementation UIView (FP_GetCurrentResponseKit)

/**根据类型获得当前的视图的VC*/
- (UIViewController *)viewController {
    return (UIViewController *)[self getResponderFromClass:UIViewController.class];
}

/**@abstract  查找view的nextResponder，直到找到类型为class的Responder*/
- (UIResponder *)getResponderFromClass:(Class)Cls {
    UIResponder *nextResponder = self;
    while (nextResponder) {
        nextResponder = nextResponder.nextResponder;
        if ([nextResponder isKindOfClass:Cls]) {
            return nextResponder;
        }
    }
    return nil;
}


@end
